1861B - Two Binary Strings - CodeForces Solution


greedy

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
using namespace std;


#define FOR(i,n) for(int i=0; i<n; i++)
#define FOR1(i,n) for(int i=1; i<=n; i++)
#define E cout << '\n'
#if !ONLINE_JUDGE
#define DB(a,n) for(int loop_iii=0; loop_iii<n; loop_iii++) { cout << a[loop_iii] << ' '; } cout << '\n'
#else
#define DB(a,n) 
#endif

typedef long long ll;
typedef pair<int ,int> pii;  
typedef pair<ll, ll> pll;
#define xx first
#define yy second

typedef tuple<int, int, int> int3;
#define g0(x) get<0>(x)
#define g1(x) get<1>(x)
#define g2(x) get<2>(x)
#define g3(x) get<3>(x)
#define g4(x) get<4>(x)

//const int MOD =  998244353;
//const int MOD = 1000000007;



const int DMAX = 200000;
//int a[DMAX];
//int b[DMAX];
//int c[DMAX];
//int d[DMAX];

int main() {
#if !ONLINE_JUDGE && 1
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
#if !ONLINE_JUDGE
    auto start =  std::chrono::high_resolution_clock::now();
#endif
#if ONLINE_JUDGE
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
#endif
    
    //unordered_map<int, int> mii;
 
    int set_count = 1;
    cin >> set_count;
    for(int set_number=0; set_number<set_count; set_number++) {
        //memset(arr, 0, sizeof(int)*DMAX);
        string a, b; cin >> a >> b;
        int n = a.length();
        bool isok = false;
        int i = 0;
        while (i<n-1) {
            if ((a[i]==b[i]) && (a[i]=='0')) {
                if ((a[i+1]==b[i+1]) && (a[i+1]=='1')) {
                    isok = true;
                    break;
                }
            }
            i++;
        }
        cout << (isok ? "YES\n" : "NO\n");
        //FOR(i,n) cin >> a[i];
        
        
        
        ;;
    }
#if !ONLINE_JUDGE
    auto stop =  std::chrono::high_resolution_clock::now();
    std::cout << '\n' << std::chrono::duration_cast<std::chrono::milliseconds>(stop-start).count()  << " milliseconds\n";
#endif
    return 0;
}
    


Comments

Submit
0 Comments
More Questions

Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum
Two Strings
Anagrams
Prime Number